<?php
/**
 * 描述：会员管理中心-订阅设置。
 * @final
 */
final class Exec_MC_Subscription_Set extends Exec_MC_Master
{
    public function Get()
    {
        #定义标量
        $data=NULL;

        #获取数据
        $account=DB::GetRowByValue('news_subscription','Account',Account::Session('Username'));
        if($account)
        {
            $account=array_slice($account,3,count($account));
            foreach($account as $key=>$value)
            {
                if(!is_numeric($key)){
                    $data.=($key.':'.$value.'|');
                }
            }
        }        

        #绑定模板
        View::Assign('SubscriptionData',$data);
        $this->MasterPage_Display(View::Fetch('mc/subscription/set.tpl'));
    }

    public function Post()
    {
        #获取数据
        $data=array();
        Functions::FormArgs('Shipyard_Conjuncture')=='1' ? $data['Shipyard_Conjuncture']='1':$data['Shipyard_Conjuncture']='0';
        Functions::FormArgs('Shipyard_Trends')=='1' ? $data['Shipyard_Trends']='1':$data['Shipyard_Trends']='0';
        Functions::FormArgs('Shipyard_Ordersheet')=='1' ? $data['Shipyard_Ordersheet']='1':$data['Shipyard_Ordersheet']='0';
        Functions::FormArgs('Shipyard_Analysis')=='1' ? $data['Shipyard_Analysis']='1':$data['Shipyard_Analysis']='0';

        Functions::FormArgs('Ancillary_News')=='1' ? $data['Ancillary_News']='1':$data['Ancillary_News']='0';
        Functions::FormArgs('Ancillary_Company')=='1' ? $data['Ancillary_Company']='1':$data['Ancillary_Company']='0';
        Functions::FormArgs('Ancillary_Ordersheet')=='1' ? $data['Ancillary_Ordersheet']='1':$data['Ancillary_Ordersheet']='0';
        Functions::FormArgs('Ancillary_Steels')=='1' ? $data['Ancillary_Steels']='1':$data['Ancillary_Steels']='0';

        Functions::FormArgs('Shipping_Market')=='1' ? $data['Shipping_Market']='1':$data['Shipping_Market']='0';
        Functions::FormArgs('Shipping_Trends')=='1' ? $data['Shipping_Trends']='1':$data['Shipping_Trends']='0';

        Functions::FormArgs('Maritimeworks_Trends')=='1' ? $data['Maritimeworks_Trends']='1':$data['Maritimeworks_Trends']='0';
        Functions::FormArgs('Maritimeworks_Ordersheet')=='1' ? $data['Maritimeworks_Ordersheet']='1':$data['Maritimeworks_Ordersheet']='0';

        Functions::FormArgs('Data_New')=='1' ? $data['Data_New']='1':$data['Data_New']='0';
        Functions::FormArgs('Data_Scrap')=='1' ? $data['Data_Scrap']='1':$data['Data_Scrap']='0';
        Functions::FormArgs('Data_Shipping')=='1' ? $data['Data_Shipping']='1':$data['Data_Shipping']='0';
        Functions::FormArgs('Data_Steels')=='1' ? $data['Data_Steels']='1':$data['Data_Steels']='0';
        Functions::FormArgs('Data_Second')=='1' ? $data['Data_Second']='1':$data['Data_Second']='0';
        Functions::FormArgs('Data_Rent')=='1' ? $data['Data_Rent']='1':$data['Data_Rent']='0';

        Functions::FormArgs('Finacing_Policy')=='1' ? $data['Finacing_Policy']='1':$data['Finacing_Policy']='0';
        Functions::FormArgs('Finacing_Cooperation')=='1' ? $data['Finacing_Cooperation']='1':$data['Finacing_Cooperation']='0';
        Functions::FormArgs('Finacing_Trends')=='1' ? $data['Finacing_Trends']='1':$data['Finacing_Trends']='0';
        Functions::FormArgs('Finacing_IPO')=='1' ? $data['Finacing_IPO']='1':$data['Finacing_IPO']='0';

        Functions::FormArgs('ShipType')=='1' ? $data['ShipType']='1':$data['ShipType']='0';
        Functions::FormArgs('Law')=='1' ? $data['Law']='1':$data['Law']='0';
        Functions::FormArgs('Technology')=='1' ? $data['Technology']='1':$data['Technology']='0';
        Functions::FormArgs('Standard')=='1' ? $data['Standard']='1':$data['Standard']='0';
        Functions::FormArgs('Topic')=='1' ? $data['Topic']='1':$data['Topic']='0';
        Functions::FormArgs('Interview')=='1' ? $data['Interview']='1':$data['Interview']='0';
        Functions::FormArgs('Observe')=='1' ? $data['Observe']='1':$data['Observe']='0';

        #更新数据
        $account=Account::Session('Username');
        $subscriptionData=DB::GetRowByValue('news_subscription','Account',$account);
        if($subscriptionData){
            DB::UpdateRowByID('news_subscription','ID:'.$subscriptionData['ID'],$data);
        }
        else
        {
            $data['Account']=$account;
            DB::Insert('news_subscription',$data);
        }
        echo 'Succeed';
    }
}
?>